<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑订单</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header th:replace="common/cms_top"></header>
<div class="container mt-4">
    <h1>编辑订单 <span th:text="${session.order.orderid}"></span></h1>
    <form th:action="@{/order/update}" method="post">

        <!-- 基本信息 -->
        <div class="card mb-4">
            <div class="card-header bg-primary text-white">基本信息</div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">订单ID</label>
                            <input type="text" class="form-control"
                                   name="orderid"
                                   th:value="${session.order.orderid}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">用户ID</label>
                            <input type="text" class="form-control"
                                   name="userid"
                                   th:value="${session.order.userid}" readonly>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">订单日期</label>
                            <span class="form-control" th:text="${session.order.orderdate}"></span>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">总金额</label>
                            <input type="number" step="0.01" class="form-control"
                                   name="totalprice"
                                   th:value="${session.order.totalprice}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">地区</label>
                            <input type="text" class="form-control"
                                   name="locale"
                                   th:value="${session.order.locale}">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 账单信息 -->
        <div class="card mb-4">
            <div class="card-header bg-success text-white">账单信息</div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">名字</label>
                            <input type="text" class="form-control"
                                   name="billtofirstname"
                                   th:value="${session.order.billtofirstname}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">地址行1</label>
                            <input type="text" class="form-control"
                                   name="billaddr1"
                                   th:value="${session.order.billaddr1}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">城市</label>
                            <input type="text" class="form-control"
                                   name="billcity"
                                   th:value="${session.order.billcity}">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">姓氏</label>
                            <input type="text" class="form-control"
                                   name="billtolastname"
                                   th:value="${session.order.billtolastname}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">地址行2</label>
                            <input type="text" class="form-control"
                                   name="billaddr2"
                                   th:value="${session.order.billaddr2}">
                        </div>
                        <div class="row">
                            <div class="col-4">
                                <div class="mb-3">
                                    <label class="form-label">州</label>
                                    <input type="text" class="form-control"
                                           name="billstate"
                                           th:value="${session.order.billstate}">
                                </div>
                            </div>
                            <div class="col-4">
                                <div class="mb-3">
                                    <label class="form-label">邮编</label>
                                    <input type="number" class="form-control"
                                           name="billzip"
                                           th:value="${session.order.billzip}">
                                </div>
                            </div>
                            <div class="col-4">
                                <div class="mb-3">
                                    <label class="form-label">国家</label>
                                    <input type="text" class="form-control"
                                           name="billcountry"
                                           th:value="${session.order.billcountry}">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 收货信息 -->
        <div class="card mb-4">
            <div class="card-header bg-warning text-dark">收货信息</div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">收货名字</label>
                            <input type="text" class="form-control"
                                   name="shiptofirstname"
                                   th:value="${session.order.shiptofirstname}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">地址行1</label>
                            <input type="text" class="form-control"
                                   name="shipaddr1"
                                   th:value="${session.order.shipaddr1}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">城市</label>
                            <input type="text" class="form-control"
                                   name="shipcity"
                                   th:value="${session.order.shipcity}">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">收货姓氏</label>
                            <input type="text" class="form-control"
                                   name="shiptolastname"
                                   th:value="${session.order.shiptolastname}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">地址行2</label>
                            <input type="text" class="form-control"
                                   name="shipaddr2"
                                   th:value="${session.order.shipaddr2}">
                        </div>
                        <div class="row">
                            <div class="col-4">
                                <div class="mb-3">
                                    <label class="form-label">州</label>
                                    <input type="text" class="form-control"
                                           name="shipstate"
                                           th:value="${session.order.shipstate}">
                                </div>
                            </div>
                            <div class="col-4">
                                <div class="mb-3">
                                    <label class="form-label">邮编</label>
                                    <input type="number" class="form-control"
                                           name="shipzip"
                                           th:value="${session.order.shipzip}">
                                </div>
                            </div>
                            <div class="col-4">
                                <div class="mb-3">
                                    <label class="form-label">国家</label>
                                    <input type="text" class="form-control"
                                           name="shipcountry"
                                           th:value="${session.order.shipcountry}">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 支付信息 -->
        <div class="card mb-4">
            <div class="card-header bg-danger text-white">支付信息</div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">信用卡号</label>
                            <input type="text" class="form-control"
                                   name="creditcard"
                                   th:value="${session.order.creditcard}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">快递方式</label>
                            <input type="text" class="form-control"
                                   name="courier"
                                   th:value="${session.order.courier}">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">有效期</label>
                            <input type="month" class="form-control"
                                   name="exprdate"
                                   th:value="${session.order.exprdate}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">卡类型</label>
                            <select class="form-select" name="cardtype">
                                <option value="Visa" th:selected="${session.order.cardtype} == 'Visa'">Visa</option>
                                <option value="MasterCard" th:selected="${session.order.cardtype} == 'MasterCard'">MasterCard</option>
                                <option value="American Express" th:selected="${session.order.cardtype} == 'American Express'">American Express</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="d-grid gap-2 d-md-flex justify-content-md-end">
            <a href="/orders" class="btn btn-secondary">取消</a>
            <button type="submit" class="btn btn-success text-white">保存修改</button>
        </div>
    </form>
</div>
<footer th:replace="common/bottom"></footer>
</body>
</html>